IDEA 2021 SSM框架使用easycode生成代码 |
您所在的位置:网站首页 › idea mybatis自动生成代码 › IDEA 2021 SSM框架使用easycode生成代码 |
1、打开菜单File-New-Project,如下图所示,填写Name,Java版本选择8,然后Next 2、选择以下五项,然后Finish 3、打开菜单File-Settings-Plugins,在搜索框中输入easy code,找到如图所示的插件install,安装完成后Apply,OK。 4、打开菜单File-Settings-Easy Code,从本地导入,选择模板文件OK,选择COVER,OK完成导入。 5、点击右侧Database,+,选择Data Source, MySQL,填写用户名,密码和要连接的数据库名,Test Connection成功后Apply OK。(如果提示驱动未下载,由点击Driver Download下载后再Test) 6、点击右侧Database,打开第5步中连接的数据库,找到要生成代码的表,在表名上右键,Easy Code,Generate Code,打开如下对话框,选择Package,选中All,统一配置,弹框选是,OK。 此时会自动生成很多Java文件,项目结构目录如下图所示: 7、打开位于src/main/resources/下的文件appliction.properties,加入以下配置 ##配置数据驱动信息 (key固定) spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver spring.datasource.url = jdbc:mysql://localhost:3306/test spring.datasource.username = root spring.datasource.password = 123456 #tomcat端口号 server.port=8081 ##给mybatis的实体类取别名 typeAliasesPackage mybatis.type-aliases-package=com.example.ssmdemo.entity ## mybatis :mapper存放位置 mybatis.mapper-locations:classpath*:/mapper/*.xml spring.mvc.pathmatch.matching-strategy=ant_path_matcher spring.main.allow-circular-references=true #分页插件 pagehelper.helper-dialect=mysql pagehelper.reasonable=true pagehelper.support-methods-arguments=true pagehelper.params=count=countSql修改以下四处配置
8、打开项目启动文件SsmDemoAppliction.java,加入@MapperScan("xxx")注解,xxx是dao文件的包名 9、打开文件pom.xml,在dependencies标签中加入以下内容,保存后点击右上角的maven重加载按钮 com.github.pagehelper pagehelper-spring-boot-starter 1.2.5 org.projectlombok lombok 1.16.1010、启动服务器,看到如下输出说明服务器正常启动。 11、在浏览器中输入http://localhost:8081/student/get/1 ,有返回证明配置成功。 8081:服务器端口号 student:表名 1:id |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |